/// @file
/// @author Chelsey Batchelor <vadedeyes@gmail.com>
/// @author Abraham Escamilla <abraham.escamilla@live.com>
/// @author Curtis Hollibaugh <curtis.hollibaugh@gmail.com>
/// @copyright Copyright 2014 Chelsey Batchelor <vadedeyes@gmail.com>
/// @copyright Copyright 2014 Abraham Escamilla <abraham.escamilla@live.com>
/// @copyright Copyright 2014 Curtis Hollibaugh <curtis.hollibaugh@gmail.com>
/// Contains definitions for the Gtk class.

#include "gtk.hpp"

using std::lock_guard;
using std::mutex;
using std::string;

mutex Gtk::gtkMutex{};

GtkStatusIcon* Gtk::CreateStatusIcon() {
	lock_guard<mutex> lock{gtkMutex};
	return gtk_status_icon_new();
}

GtkStatusIcon* Gtk::CreateStatusIcon(const string& filename) {
	lock_guard<mutex> lock{gtkMutex};
	return gtk_status_icon_new_from_file(filename.c_str());
}

void Gtk::DestroyStatusIcon(GtkStatusIcon* statusIcon) {
	lock_guard<mutex> lock{gtkMutex};
	g_object_unref(G_OBJECT(statusIcon));
}

bool Gtk::GetIsVisible(GtkStatusIcon* statusIcon) {
	lock_guard<mutex> lock{gtkMutex};
	return gtk_status_icon_get_visible(statusIcon);
}

void Gtk::Init() {
	lock_guard<mutex> lock{gtkMutex};
	gtk_init(0, nullptr);
}

void Gtk::MainIterationDo(bool blocking) {
	lock_guard<mutex> lock{gtkMutex};
	gtk_main_iteration_do(blocking);
}

void Gtk::SetIsVisible(GtkStatusIcon* statusIcon, bool visible) {
	lock_guard<mutex> lock{gtkMutex};
	gtk_status_icon_set_visible(statusIcon, visible);
}
